package com.ruoyi.vhr.employee.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.vhr.employee.domain.VhrEmployee;
import com.ruoyi.vhr.employee.service.IVhrEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * vhr的员工管理Controller
 * 
 * @author gxl
 * @date 2024-03-18
 */
@RestController
@RequestMapping("/employee/employee")
public class VhrEmployeeController extends BaseController
{
    @Autowired
    private IVhrEmployeeService vhrEmployeeService;

    /**
     * 查询vhr的员工管理列表
     */
    @PreAuthorize("@ss.hasPermi('employee:employee:list')")
    @GetMapping("/list")
    public TableDataInfo list(VhrEmployee vhrEmployee)
    {
        startPage();
        List<VhrEmployee> list = vhrEmployeeService.selectVhrEmployeeList(vhrEmployee);
        return getDataTable(list);
    }

    /**
     * 导出vhr的员工管理列表
     */
    @PreAuthorize("@ss.hasPermi('employee:employee:export')")
    @Log(title = "vhr的员工管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VhrEmployee vhrEmployee)
    {
        List<VhrEmployee> list = vhrEmployeeService.selectVhrEmployeeList(vhrEmployee);
        ExcelUtil<VhrEmployee> util = new ExcelUtil<VhrEmployee>(VhrEmployee.class);
        util.exportExcel(response, list, "vhr的员工管理数据");
    }

    /**
     * 获取vhr的员工管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('employee:employee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(vhrEmployeeService.selectVhrEmployeeById(id));
    }

    /**
     * 新增vhr的员工管理
     */
    @PreAuthorize("@ss.hasPermi('employee:employee:add')")
    @Log(title = "vhr的员工管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VhrEmployee vhrEmployee)
    {
        return toAjax(vhrEmployeeService.insertVhrEmployee(vhrEmployee));
    }

    /**
     * 修改vhr的员工管理
     */
    @PreAuthorize("@ss.hasPermi('employee:employee:edit')")
    @Log(title = "vhr的员工管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VhrEmployee vhrEmployee)
    {
        return toAjax(vhrEmployeeService.updateVhrEmployee(vhrEmployee));
    }

    /**
     * 删除vhr的员工管理
     */
    @PreAuthorize("@ss.hasPermi('employee:employee:remove')")
    @Log(title = "vhr的员工管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vhrEmployeeService.deleteVhrEmployeeByIds(ids));
    }
}
